package graphic;

import objects.Dir;
import objects.Mill;
import objects.Text2dPrinter;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;

/**
 *  
 * @author Bartek & Marcin
 * 
 * @description service the loading Page
 */
public class LoadingFrame {
    private Mill mill;
    private Text2dPrinter wr = new Text2dPrinter();
    private String txt = "Ladowanie ";
    public LoadingFrame(){
        GL11.glClearColor(1.0f, 1.0f, 1.0f,1.0f); 
        mill = new Mill(0.0f, 0.0f, 0.0f,0.2f);
        mill.speed = 20;
        Sun.set(0.2f);
        wr.setFont("GolonkaFA.otf", 30);
        wr.setColor(org.newdawn.slick.Color.darkGray);
        Graphic.e.unbind();
        Camera.rot(-3600);
        Camera.bdegree= 1.5f;
        Camera.moveVert(Dir.UP);
        Camera.moveVert(Dir.UP);
        Camera.moveVert(Dir.UP);
        Camera.moveVert(Dir.UP);      
    }
    public void updateSplash(){
        Graphic.e.clear();
        Graphic.e.start3D();
        Camera.refresh();
        Sun.refresh();
        Graphic.e.setColor(new Color(1.0f,1.0f,1.0f,1.0f));
        mill.draw();
        Graphic.e.start2D();
        wr.write(10, 10, txt);
        Graphic.e.unbind();        
        if(txt.equals("Ladowanie ....")) {txt ="Ladowanie ";}
        txt+=".";
        Display.update();
        Display.sync(60);
    }
    public void endSplash(){
        GL11.glClearColor(0.9f, 0.9f, 0.9f,1.0f);   
        Camera.moveVert(Dir.DOWN);
        Camera.moveVert(Dir.DOWN);
        Camera.moveVert(Dir.DOWN);
        Camera.moveVert(Dir.DOWN);
        Camera.bdegree= 0.0f;
        Camera.rot(3600);
    }
}